<template>
  <div>
    <el-card shadow="never" class="mb20">
      <start-title ref="startTitle" />
    </el-card>
    <el-card shadow="never">
      <start-tabs ref="startTabs" />
    </el-card>
  </div>
</template>

<script>
import StartTitle from './StartTitle'
import StartTabs from './StartTabs'
import { getSession, setSession, removeSession } from '@/utils/util'
import { taskDetail } from '@/api/eval'

export default {
  components: {
    StartTitle,
    StartTabs
  },
  data() {
    return {
      row: this.$route.params.row || getSession('startTestRow')
    }
  },
  async created() {
    if (JSON.stringify(this.$route.params) !== '{}') {
      setSession('startTestRow', this.$route.params.row)
    }
    console.log('testRow', this.row)
    if (this.row) {
      const res = await taskDetail(this.row.evalPlanId)
      this.$refs.startTabs.getData(res.data)
    } else {
      this.$message.error('页面发生错误，即将跳转回列表页')
      setTimeout(() => {
        // this.$router.push({
        //   name: 'evaluatePlan'
        // })
        this.$router.push({
          name: 'evaluateMyPlan'
        })
      }, 1000)
    }
  }
  // destroyed() {
  //   removeSession('startTestRow')
  // }
}
</script>
